home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / sst115j.lzh / SSTFOS.C < prev    next >
C/C++ Source or Header  |  1992-08-01  |  12KB  |  365 lines

  1. /* ------------------------------------------------------------------------ */
  2. /*                                 sstfoss.c                                */
  3. /*                                                                          */
  4. /*                   Revision 5  FOSSIL interface layer                     */
  5. /*      CopyRight (C) 1991,1992  Steven Lutrov.   All rights reserved.      */
  6. /* ------------------------------------------------------------------------ */
  7. #include <dos.h>
  8. #include "sstfos.h"
  9.  
  10. /* ------------------------------------------------------------------------ */
  11. /*                      function 0x00 - Set baud rate                       */
  12. /* ------------------------------------------------------------------------ */
  13. unsigned int finit(unsigned int p, unsigned int b)
  14. {
  15.     _AH = 0x00;
  16.     _AL = b;
  17.     _DX = p;
  18.     geninterrupt(0x14);
  19.     return(_AX);
  20. }
  21.  
  22. /* ------------------------------------------------------------------------ */
  23. /*               function 0x01 Transmit character with wait                 */
  24. /* ------------------------------------------------------------------------ */
  25. unsigned int fputch(unsigned int p, char c)
  26. {
  27.     _AH = 0x01;
  28.     _AL = c;
  29.     _DX = p;
  30.     geninterrupt(0x14);
  31.     return(_AX);
  32. }
  33.  
  34. /* ------------------------------------------------------------------------ */
  35. /*               function 0x02 Receive character with wait                  */
  36. /* ------------------------------------------------------------------------ */
  37. unsigned int fgetch(unsigned int p)
  38. {
  39.     _AH = 0x02;
  40.     _DX = p;
  41.     geninterrupt(0x14);
  42.     return(_AX);
  43. }
  44.  
  45. /* ------------------------------------------------------------------------ */
  46. /*                      function 0x03 Request status                        */
  47. /* ------------------------------------------------------------------------ */
  48. unsigned int fstatus(unsigned int p)
  49. {
  50.     _AH = 0x03;
  51.     _DX = p;
  52.     geninterrupt(0x14);
  53.     return(_AX);
  54. }
  55.  
  56. /* ------------------------------------------------------------------------ */
  57. /*                     function 0x04 initialize driver                      */
  58. /* ------------------------------------------------------------------------ */
  59. unsigned int ffinit(unsigned int p, unsigned int *f, char far *fb)
  60. {
  61.     _AH = 0x04;
  62.     _BX = *f;
  63.     if (_BX == 0x4F50) {
  64.         _ES = FP_SEG(fb);
  65.         _CX = FP_OFF(fb);
  66.     }
  67.     _DX = p;
  68.     geninterrupt(0x14);
  69.     _CX = _BX;
  70.     *f  = _CX;
  71.     return(_AX);
  72. }
  73.  
  74. /* ------------------------------------------------------------------------ */
  75. /*                  function 0x05 deinitialize driver                       */
  76. /* ------------------------------------------------------------------------ */
  77. void fdeinit(unsigned int p)
  78. {
  79.     _AH = 0x05;
  80.     _DX = p;
  81.     geninterrupt(0x14);
  82. }
  83.  
  84. /* ------------------------------------------------------------------------ */
  85. /*                     function 0x06 raise/lower DTR                        */
  86. /* ------------------------------------------------------------------------ */
  87. void fdtr(unsigned int p, unsigned int d)
  88. {
  89.     _AH = 0x06;
  90.     _AL = d;
  91.     _DX = p;
  92.     geninterrupt(0x14);
  93. }
  94.  
  95. /* ------------------------------------------------------------------------ */
  96. /*                function 0x07 return timer tick parameters                */
  97. /* ------------------------------------------------------------------------ */
  98. unsigned int ftickparms(unsigned int *ms)
  99. {
  100.     _AH = 0x07;
  101.     geninterrupt(0x14);
  102.     *ms = _DX;
  103.     return(_AX);
  104. }
  105.  
  106. /* ------------------------------------------------------------------------ */
  107. /*                     function 0x08 flush output buffer                    */
  108. /* ------------------------------------------------------------------------ */
  109. void fflushout(unsigned int p)
  110. {
  111.     _AH = 0x08;
  112.     _DX = p;
  113.     geninterrupt(0x14);
  114. }
  115.  
  116. /* ------------------------------------------------------------------------ */
  117. /*                    function 0x09 purge output buffer                     */
  118. /* ------------------------------------------------------------------------ */
  119. void fpurgeout(unsigned int p)
  120. {
  121.     _AH = 0x09;
  122.     _DX = p;
  123.     geninterrupt(0x14);
  124. }
  125.  
  126. /* ------------------------------------------------------------------------ */
  127. /*                    function 0x0A purge input buffer                      */
  128. /* ------------------------------------------------------------------------ */
  129. void fpurgein(unsigned int p)
  130. {
  131.     _AH = 0x0A;
  132.     _DX = p;
  133.     geninterrupt(0x14);
  134. }
  135.  
  136. /* ------------------------------------------------------------------------ */
  137. /*              function 0x0B transmit character without wait               */
  138. /* ------------------------------------------------------------------------ */
  139. unsigned int fpoke(unsigned int p, char c)
  140. {
  141.     _AH = 0x0B;
  142.     _AL = c;
  143.     _DX = p;
  144.     geninterrupt(0x14);
  145.     return(_AX);
  146. }
  147.  
  148. /* ------------------------------------------------------------------------ */
  149. /*                  function 0x0C nondestructive read-ahead                 */
  150. /* ------------------------------------------------------------------------ */
  151. unsigned int fpeek(unsigned int p)
  152. {
  153.     _AH = 0x0C;
  154.     _DX = p;
  155.     geninterrupt(0x14);
  156.     return(_AX);
  157. }
  158.  
  159. /* ------------------------------------------------------------------------ */
  160. /*                  function 0x0D keyboard read without wait                */
  161. /* ------------------------------------------------------------------------ */
  162. unsigned int fkbdpeek(void)
  163. {
  164.     _AH = 0x0D;
  165.     geninterrupt(0x14);
  166.     return(_AX);
  167. }
  168.  
  169. /* ------------------------------------------------------------------------ */
  170. /*                   function 0x0E keyboard read with wait                  */
  171. /* ------------------------------------------------------------------------ */
  172. unsigned int fkbdgetch(void)
  173. {
  174.     _AH = 0x0E;
  175.     geninterrupt(0x14);
  176.     return(_AX);
  177. }
  178.  
  179. /* ------------------------------------------------------------------------ */
  180. /*                function 0x0F enable or disable flow control              */
  181. /* ------------------------------------------------------------------------ */
  182. void fflow(unsigned int p, unsigned char m)
  183. {
  184.     _AH = 0x0F;
  185.     _AL = m;
  186.     _DX = p;
  187.     geninterrupt(0x14);
  188. }
  189.  
  190. /* ------------------------------------------------------------------------ */
  191. /*      function 0x10 extended control-C/-K checking and transmit on/off    */
  192. /* ------------------------------------------------------------------------ */
  193. unsigned int fcontrol(unsigned int p, unsigned char m)
  194. {
  195.     _AH = 0x10;
  196.     _AL = m;
  197.     _DX = p;
  198.     geninterrupt(0x14);
  199.     return(_AX);
  200. }
  201.  
  202. /* ------------------------------------------------------------------------ */
  203. /*                 function 0x11 set current cursor location                */
  204. /* ------------------------------------------------------------------------ */
  205. void fgotoxy(unsigned int x, unsigned int y)
  206. {
  207.     _AH = 0x11;
  208.     _DL = x;
  209.     _DH = y;
  210.     geninterrupt(0x14);
  211. }
  212.  
  213. /* ------------------------------------------------------------------------ */
  214. /*                 function 0x12 read current cursor location               */
  215. /* ------------------------------------------------------------------------ */
  216. unsigned int fwherexy(unsigned int *x, unsigned int *y)
  217. {
  218.     _AH = 0x12;
  219.     geninterrupt(0x14);
  220.     if (x)
  221.         *x = _DL;
  222.     if (y)
  223.         *y = _DH;
  224.     return(_DX);
  225. }
  226.  
  227. /* ------------------------------------------------------------------------ */
  228. /*            function 0x13 single character ANSI write to screen           */
  229. /* ------------------------------------------------------------------------ */
  230. void fdispansi(char c)
  231. {
  232.     _AH = 0x13;
  233.     _AL = c;
  234.     geninterrupt(0x14);
  235. }
  236.  
  237. /* ------------------------------------------------------------------------ */
  238. /*       function 0x14 enable or disable carrier watchdog processing        */
  239. /* ------------------------------------------------------------------------ */
  240. void fwatchdog(unsigned int p, int f)
  241. {
  242.     _AH = 0x14;
  243.     _AL = f;
  244.     _DX = p;
  245.     geninterrupt(0x14);
  246. }
  247.  
  248. /* ------------------------------------------------------------------------ */
  249. /*              function 0x15 write character to screen via BIOS            */
  250. /* ------------------------------------------------------------------------ */
  251. void fdispbios(char c)
  252. {
  253.     _AH = 0x15;
  254.     _AL = c;
  255.     geninterrupt(0x14);
  256. }
  257.  
  258. /* ------------------------------------------------------------------------ */
  259. /*   function 0x16 insert or delete a function from the timer tick chain    */
  260. /* ------------------------------------------------------------------------ */
  261. unsigned int ftickchain(int a, void (far *func)())
  262. {
  263.     _AH = 0x16;
  264.     _AL = a;
  265.     _ES = FP_SEG(func);
  266.     _DX = FP_OFF(func);
  267.     geninterrupt(0x14);
  268.     return(_AX);
  269. }
  270.  
  271. /* ------------------------------------------------------------------------ */
  272. /*                       function 0x17 reboot system                        */
  273. /* ------------------------------------------------------------------------ */
  274. void freboot(unsigned int w)
  275. {
  276.     _AH = 0x17;
  277.     _AL = w;
  278.     geninterrupt(0x14);
  279. }
  280.  
  281. /* ------------------------------------------------------------------------ */
  282. /*                     function 0x18 read block transfer                    */
  283. /* ------------------------------------------------------------------------ */
  284. unsigned int fgetblk(unsigned int p, void far *buf, unsigned int z)
  285. {
  286.     _AH = 0x18;
  287.     _ES = FP_SEG(buf);
  288.     _DI = FP_OFF(buf);
  289.     _CX = z;
  290.     _DX = p;
  291.     geninterrupt(0x14);
  292.     return(_AX);
  293. }
  294.  
  295. /* ------------------------------------------------------------------------ */
  296. /*                      function 0x19 write block transfer                  */
  297. /* ------------------------------------------------------------------------ */
  298. unsigned int fputblk(unsigned int p, void far *buf, unsigned int z)
  299. {
  300.     _AH = 0x19;
  301.     _ES = FP_SEG(buf);
  302.     _DI = FP_OFF(buf);
  303.     _CX = z;
  304.     _DX = p;
  305.     geninterrupt(0x14);
  306.     return(_AX);
  307. }
  308.  
  309. /* ------------------------------------------------------------------------ */
  310. /*                      function 0x1A break begin or end                    */
  311. /* ------------------------------------------------------------------------ */
  312. void fbreak(unsigned int p, unsigned int f)
  313. {
  314.     _AH = 0x1A;
  315.     _AL = f;
  316.     _DX = p;
  317.     geninterrupt(0x14);
  318. }
  319.  
  320. /* ------------------------------------------------------------------------ */
  321. /*               function 0x1B return information about driver              */
  322. /* ------------------------------------------------------------------------ */
  323. unsigned int finfo(unsigned int p, void far *buf, unsigned int z)
  324. {
  325.     _AH = 0x1B;
  326.     _ES = FP_SEG(buf);
  327.     _DI = FP_OFF(buf);
  328.     _CX = z;
  329.     _DX = p;
  330.     geninterrupt(0x14);
  331.     return(_AX);
  332. }
  333.  
  334. /* ------------------------------------------------------------------------ */
  335. /*          function 0x7E install an "external application" function        */
  336. /* ------------------------------------------------------------------------ */
  337. unsigned int faddapp(unsigned int p, unsigned int *c, void (far *func)())
  338. {
  339.     _AH = 0x7E;
  340.     _AL = *c;
  341.     _ES = FP_SEG(func);
  342.     _DX = FP_OFF(func);
  343.     _DX = p;
  344.     geninterrupt(0x14);
  345.     *c = _BX;
  346.     return(_AX);
  347. }
  348.  
  349. /* ------------------------------------------------------------------------ */
  350. /*         function 0x7F remove an "external application" function          */
  351. /* ------------------------------------------------------------------------ */
  352. unsigned int fdelapp(unsigned int p, unsigned int *c, void (far *func)())
  353. {
  354.     _AH = 0x7F;
  355.     _AL = *c;
  356.     _ES = FP_SEG(func);
  357.     _DX = FP_OFF(func);
  358.     _DX = p;
  359.     geninterrupt(0x14);
  360.     *c = _BX;
  361.     return(_AX);
  362. }
  363.  
  364.  
  365.